import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger';
import { 
  IsNotEmpty, 
  IsString, 
  IsUUID, 
  IsOptional, 
  IsEnum, 
  IsDateString 
} from 'class-validator';
import { Priority, TaskStatus } from '../../../types/enums';

export class CreateTaskDto {
  @ApiProperty({
    description: '任务标题',
    example: '完成登录页面设计',
  })
  @IsNotEmpty({ message: '任务标题不能为空' })
  @IsString({ message: '任务标题必须是字符串' })
  title: string;

  @ApiProperty({
    description: '任务描述',
    example: '根据UI设计稿完成登录页面的前端实现，包括表单验证和错误提示。',
  })
  @IsNotEmpty({ message: '任务描述不能为空' })
  @IsString({ message: '任务描述必须是字符串' })
  description: string;

  @ApiProperty({
    description: '所属项目ID',
    example: '123e4567-e89b-12d3-a456-426614174000',
  })
  @IsNotEmpty({ message: '项目ID不能为空' })
  @IsUUID('4', { message: '项目ID必须是有效的UUID' })
  projectId: string;

  @ApiPropertyOptional({
    description: '指派给谁',
    example: '123e4567-e89b-12d3-a456-426614174000',
  })
  @IsOptional()
  @IsUUID('4', { message: '指派人ID必须是有效的UUID' })
  assigneeId?: string;

  @ApiPropertyOptional({
    description: '任务状态',
    enum: TaskStatus,
    default: TaskStatus.TODO,
    example: TaskStatus.TODO,
  })
  @IsOptional()
  @IsEnum(TaskStatus, { message: '任务状态无效' })
  status?: TaskStatus = TaskStatus.TODO;

  @ApiPropertyOptional({
    description: '优先级',
    enum: Priority,
    default: Priority.MEDIUM,
    example: Priority.MEDIUM,
  })
  @IsOptional()
  @IsEnum(Priority, { message: '优先级无效' })
  priority?: Priority = Priority.MEDIUM;

  @ApiProperty({
    description: '开始日期',
    example: '2023-01-01T00:00:00Z',
  })
  @IsNotEmpty({ message: '开始日期不能为空' })
  @IsDateString({}, { message: '开始日期格式无效' })
  startDate: string;

  @ApiProperty({
    description: '截止日期',
    example: '2023-01-15T00:00:00Z',
  })
  @IsNotEmpty({ message: '截止日期不能为空' })
  @IsDateString({}, { message: '截止日期格式无效' })
  dueDate: string;
} 